<?php
include("../design/header.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script language="javascript" src="../scripts/engine.js"></script>
<script language="javascript" src="../scripts/rule.js"></script>

<link rel="stylesheet" type="text/css" href="../design/main.css" />
<title>Create Reports</title>
</head>
<body>
<?php

require_once("../../business/RetrieveComboData.php");
require_once("../../business/util/Utility.php");

$comboObj = new RetrieveComboData();

?>

<table id="mainTable" width="100%" class="mainTableHeight1024x768" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td width="50" valign="top" class="LeftBgColor">&nbsp;<?php include("../design/leftMenu.php"); ?>
	</td>
    <td valign="top">


<table id="table1" name="table1" align="center" cellpadding="0" cellspacing="0" border="0" >
<form id="form1" name="form1" method="post" action="">

	<tr>
    	<td colspan="8">&nbsp;</td>
        <td><input type="hidden" id="criteria_counter" name="criteria_counter" value="1"></td>
        <td><input type="hidden" id="arrAlias" name="arrAlias[]" ></td>
    </tr>
    
    <tr>
    	<td colspan="10">&nbsp;</td>
    </tr>
    
    <tr>
		<td class="Labels" >Select the Tables</td>    
        <td>
     
    <select name="tblName" id="tblName" multiple size="5" class="InputText" onClick='loadTableSet()'>
    <?php
    	$table_names =  $comboObj->getTableNames();
		$i=0;
		
		foreach($table_names as $arr){
		
	?>
		<option value="<?php echo $arr;?>" selected><?php echo $arr;?>
       
    <?php	
		$i++;
		}
	?>
       	 
         

    </select>
     </td>
     
     <td class="Labels">Query</td>
        <td colspan="6">
         	<textarea id="text_query" name="text_query" rows="6" cols="61" class="InputText">Select</textarea>
         </td>   

      	</tr>
    <tr>
    	<td colspan="10">&nbsp;</td>
    </tr>
        <tr>
    	<td colspan="7">&nbsp;</td>
        <td><input type="button" id="btn_report" name="btn_report" class="InputButton" value="Generate Report" disabled onClick="submitReport()"></td>
    </tr>
    <tr>
    	<td class="Labels"> Build the Query </td>
    </tr>
    
    <tr>
    	<td colspan="10">&nbsp;</td>
    </tr>
    
    <tr>
    	<td class="Labels">Field</td>
        <td>

        <select name="combo_field[]" id="combo_field0" class="InputComboList">
        
            <?php
            	$options= $comboObj->getFieldNames($table_names);
				$arr = getTokenizedArray($options,",");
				$size=sizeof($arr);
				for($i=0; $i<$size; $i++){
			?>
            	<option value='<?php echo $arr[$i];?>' ><? echo $arr[$i];?></option>
			<?php			
				}
			?>
        </select>
        
        </td>
        <td class="Labels">Alias</td>
        <td><input type="text" class="InputText" id="text_alias0" name="text_alias[]"></td>
        <td class="Labels">Sort</td>
        <td>
        	<select id="combo_sort0" name="combo_sort[]" class="InputComboList">
       	        <option value="0">Select</option>
            	<option value="ASC">Ascending</option>
                <option value="DSC">Descending</option>
            </select>
        </td>
        <td class="Labels">Criteria</td>
        <td>
<!--        <textarea name="text_criteria[]" id="text_criteria0" cols=20 rows=3 class="InputText"></textarea>-->
        <input type="text" class="InputText" id="text_criteria0" name="text_criteria[]">
        </td>
        <td><input type="button" class="InputButton" id="btn_Add" name="btn_Add" value="Add" onClick="addQueryRow('table1')"></td>
        <td>&nbsp;</td>
    </tr>
    
    <tr>
    	<td>&nbsp;</td>
    </tr>
    
    <tr>
    	<td colspan="10" align="center" ><input type="button" id="btn_submit" name="btn_submit" class="InputButton" value="Generate Query" onClick="loadQuery()"></td>
    </tr>
    
  </form>  
</table>
    </td>
 </tr>   
</table>


</body>
</html>